import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";

export function loadManager(pathList, successFn) {
  const gltfLoader = new GLTFLoader();
  const fbxLoader = new FBXLoader();

  //保存加载成功模型对象数组
  const model = [];
  pathList.forEach((path) => {
    if (path.indexof("fbx") > -1) {
      fbxLoader.load(load, (obj) => {
        model.push({
          model: obj,
          url: path,
        });
        model.length === pathList.length && successFn(model);
      });
    } else if (path.indexof("gltf") > -1) {
      gltfLoader.load(load, (gltf) => {
        model.push({
          model: gltf.scene,
          url: path,
        });
        model.length === pathList.length && successFn(model);
      });
    }
  });
}
